using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;
using System.Transactions;
using GC2.Entities.Admin;
using GC2.Entities.Seguridad;
using GC2.Bussines.BMSeguridad;
using GC2.ExceptionHandler.Services;
using GC2.DataAccess.DAAdmin;

namespace GC2.Bussines.BMAdmin
{
    public class BMCajas
    {
        public BMCajas(string coneccion) 
        {
            this.Connection = coneccion;
        }

        private string connection = "";
        public string Connection
        {
            get { return connection; }
            set { connection = value; }
        }

        DACajas daCajas = new DACajas();
        List<Cajas> listaCajas = new List<Cajas>();

        #region BMCajasInsertApertura
        public Cajas BMCajasInsertApertura(Cajas caja)
        {
            try
            {
                return daCajas.DACajasInsertApertura(Connection, caja);
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMCajasUpdate
        public void BMCajasUpdate(Cajas caja)
        {
            try
            {
                daCajas.DACajasUpdate(Connection, caja);
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMCajasGetOne
        public Cajas BMCajasGetOne(Cajas caja)
        {
            try
            {
                caja = daCajas.DACajasGetOne(Connection, caja);

                return caja;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMCajasGetOneById
        public Cajas BMCajasGetOneById(Cajas caja)
        {
            try
            {
                caja = daCajas.DACajasGetOneById(Connection, caja);

                return caja;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMCajasAbiertaByUsuario
        public Cajas BMCajasAbiertaByUsuario(Cajas caja)
        {
            try
            {
                Cajas oCaja = new Cajas();
                oCaja = daCajas.DACajasAbiertaByUsuario(Connection, caja);
                return oCaja;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion

        #region BMCajasSearch
        public List<Cajas> BMCajasSearch(Cajas cajaD, Cajas cajaH)
        {
            try
            {
                listaCajas = daCajas.DACajasSearch(connection, cajaD, cajaH);
                return listaCajas;
            }
            catch (Exception ex)
            {
                ExceptionBM exNew = new ExceptionBM();
                throw new System.Exception(exNew.exBM(ex.ToString()).ToString());
            }
        }
        #endregion
    }
}
